<style lang="sass" scoped>
	#side,
	.el-menu {
		height: 100%;
		width: 100%;
		border: 0;
	}
</style>
<template>
	<div id="side">
		<el-menu :default-active="activeIndex" class="el-menu-vertical-demo" background-color="#545c64" text-color="#fff" active-text-color="#ffd04b"
		 router>
			<el-submenu v-for="(item,i) in side" :key="item.name" :index="i+''" v-if="item.level===level" v-jurdie="item.jur">
				<template slot="title">
					<i class="el-icon-location"></i>
					<span>{{item.name}}</span>
				</template>
				<el-menu-item-group>
					<el-menu-item
						v-for="(item2) in item.list" :key="item2.name"
						:index="item2.url" v-jurdie="item2.jur">{{item2.name}}</el-menu-item>
				</el-menu-item-group>
			</el-submenu>
		</el-menu>
	</div>
</template>

<script>
	export default {
		components: {},
		data() {
			return {
				level:'',
				activeIndex: "",
				side:[
					{
						name:'产品管理',
						url:'',
						level:'admin',
						jur:'book1000',
						list:[
							{
								name:'产品列表',
								url:'/product/product_list',
								jur:'book1100',
							},
							{
								name:'类目列表',
								url:'/product/product_categ_list',
								jur:'book1200',
							},
							{
								name:'回收站',
								url:'/product/product_trash',
								jur:'book1300',
							},
						],
					},
					{
						name:'商品管理',
						url:'',
						level:'admin',
						jur:'book2000',
						list:[
							{
								name:'商品列表',
								url:'/item/item_list',
								jur:'book2100',
							},
							
							{
								name:'运费规则',
								url:'/item/item_fee',
								jur:'book2200',
							},
						],
					},
					{
						name:'订单管理',
						url:'',
						level:'admin',
						jur:'book3000',
						list:[
							{
								name:'订单列表',
								url:'/order/order_list',
								jur:'book3100',
							},
						],
					},
					{
						name:'售后管理',
						url:'',
						level:'admin',
						jur:'book4000',
						list:[
							{
								name:'售后列表',
								url:'/saled/saled_list',
								jur:'book4100',
							},
						],
					},
					{
						name:'分销商管理',
						url:'',
						level:'admin',
						jur:'book4000',
						list:[
							{
								name:'分销商列表',
								url:'/dis/dis_list',
								jur:'book4100',
							},
							{
								name:'提现列表',
								url:'/dis/dis_getcur_list',
								jur:'book4100',
							},
						],
					},
					{
						name:'设备联网管理',
						url:'',
						level:'admin',
						jur:'book4000',
						list:[
							{
								name:'设备联网列表',
								url:'/device/device_list',
								jur:'book4100',
							},
						],
					},
					{
						name:'首页配置',
						url:'',
						level:'admin',
						jur:'book5000',
						list:[
							{
								name:'首页模块配置',
								url:'/home/home_setting',
								jur:'book5100',
							},
						],
					},
					{
						name:'用户管理',
						url:'',
						level:'root',
						jur:'root',
						show:false,
						router:'user',
						icon:'#icon-shujuku',
						list:[
							{
								name:'用户列表',
								url:'/user/user_list',
								jur:'root',
							},
						],
					},
					{
						name:'组织管理',
						url:'',
						level:'root',
						jur:'root',
						show:false,
						router:'dept',
						icon:'#icon-shujuku',
						list:[
							{
								name:'组织管理',
								url:'/dept/dept',
								jur:'root',
							},
						],
					},
				]
			};
		},
		computed: {},
		created() { 

		},
		mounted() {
			this.$nextTick(() => {
				let userMsg = {};
				if(util.getCookie('userMsg')){
					userMsg = JSON.parse(util.getCookie('userMsg'))
				}
				this.level = userMsg.level;
				console.log(util.getCookie('userMsg'))
				setTimeout(()=>{
					this.activeIndex = this.$route.path;
				},100)
			});
		},
		methods: {}
	};
</script>